﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataControl;
using System.Data;
using System.Text;

namespace ATW.MT.BUS
{
    public class bus_C_Temp
    {
        DataAccess da = null;
        public bus_C_Temp()
        {
            da = new DataAccess();
        }
        #region 方法
        /// <summary>
        /// 温度分页查询
        /// </summary>
        /// <param name="desc"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public DataTable TempPagerQuery(string desc, int page, int pagesize)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"select * from c_temperature where 1=1");
            if (desc != "")
            {
                sql.Append(" and TDesc like '%" + desc + "%'");
            }
            return da.PageSize(sql.ToString(), page, pagesize, "TempID");
        }
        /// <summary>
        /// 温度修改
        /// </summary>
        /// <param name="desc"></param>
        /// <param name="up"></param>
        /// <param name="down"></param>
        /// <param name="rate"></param>
        /// <param name="tempID"></param>
        /// <returns></returns>
        public int TempEdit(string desc, string up, string down, string rate, string tempID)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"update C_temperature set up='{0}',down='{1}',TDesc='{2}',rate='{3}' where tempid='{4}'",
                up, down, desc, rate, tempID);
            return da.ExcuteNoQuery(sql.ToString());
        }
        /// <summary>
        /// 新增温度区间
        /// </summary>
        /// <param name="desc"></param>
        /// <param name="up"></param>
        /// <param name="down"></param>
        /// <param name="rate"></param>
        /// <returns></returns>
        public int TempAdd(string desc, string up, string down, string rate)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"insert into C_temperature(up,down,TDesc,rate) values('{0}','{1}','{2}','{3}')", up, down, desc, rate);
            return da.ExcuteNoQuery(sql.ToString());
        }
        /// <summary>
        /// 温度单条查询
        /// </summary>
        /// <param name="tid"></param>
        /// <returns></returns>
        public DataTable TempSingleQuery(string tid)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat(@"select * from c_temperature where tempid='{0}'", tid);
            return da.ExecuteDataTable(sql.ToString());
        }
        #endregion
    }
}